package main

import "fmt"

var (
	a     [1000]byte
	prog  = "++++++++++[>++++++++++<-]>++++.+."
	p, pc int
)

func main() {
	fmt.Printf("%s\n", prog)
	pc = 0
	p = 0
	s := make([]int, 20)
	si := -1
	for ; pc < len(prog); pc++ {
		switch prog[pc] {
		case '+':
			a[p]++
		case '-':
			a[p]--
		case '>':
			p++
		case '<':
			p--
		case '[':
			if a[p] == 0 {
				for prog[pc] != ']' {
					pc++
				}
			} else {
				si++
				s[si] = pc
			}
		case ']':
			if a[p] != 0 {
				pc = s[si]
			}
		case '.':
			fmt.Printf("%c", a[p])
		}
	}
	fmt.Println()
}
